<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
    <title></title>
    <!-- Bootstrap Core CSS -->
    <link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
  <script src="js/jquery.js"></script>
 
</head>

<body class="fix-header card-no-border">
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
        <header class="topbar">
            <nav class="navbar top-navbar navbar-toggleable-sm navbar-light">
                <!-- ============================================================== -->
                <!-- Logo -->
                <!-- ============================================================== -->
                <div class="navbar-header">
                    <a class="navbar-brand" href="User_book.html">
                        <!-- Logo icon -->
                        <b>
                            <!--You can put here icon as well // <i class="wi wi-sunset"></i> //-->
                            <!-- Dark Logo icon -->
                            <img src="assets/images/logo-icon.png" alt="homepage" class="dark-logo" />
                            
                        </b>
                        <!--End Logo icon -->
                        <!-- Logo text -->
                        <span>
                            <!-- dark Logo text -->
                               <img   class="dark-logo" />学生用户系统
                        </span>
                    </a>
                </div>
                <!-- ============================================================== -->
                <!-- End Logo -->
                <!-- ============================================================== -->
                <div class="navbar-collapse">
                    <!-- ============================================================== -->
                    <!-- toggle and nav items -->
                    <!-- ============================================================== -->
                    <ul class="navbar-nav mr-auto mt-md-0 ">
                        <!-- This is  -->
                        <li class="nav-item"> <a class="nav-link nav-toggler hidden-md-up text-muted waves-effect waves-dark" href="javascript:void(0)"><i class="ti-menu"></i></a> </li>
                        <li class="nav-item hidden-sm-down">
                            <form class="app-search p-l-20">
                                <input type="text" class="form-control" placeholder="近期考试繁忙，此功能请期待下一版本"> <a class="srh-btn"><i class="ti-search"></i></a>
                            </form>
                        </li>
                    </ul>
                    <!-- ============================================================== -->
                    <!-- User profile and search -->
                    <!-- ============================================================== -->
                     <h1 style="margin: auto;">广西科技大学图书管理系统</h1>
                    <ul class="navbar-nav my-lg-0">
                        <li class="nav-item dropdown">
                            <a href="#" onclick="quit()">注销</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <!-- ============================================================== -->
        <!-- End Topbar header -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <aside class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
                <!-- Sidebar navigation-->
                <nav class="sidebar-nav">
                    <ul id="sidebarnav">
                       <li>
                           <a id="a1" class="waves-effect"><i class="fa fa-table m-r-10" aria-hidden="true"></i>图书信息</a>
                       </li>
                        <li>
                            <a id="a2"  class="waves-effect"><i class="fa fa-user m-r-10" aria-hidden="true"></i>个人信息</a>
                        </li>
                       
                       
                        
                        >
                       
                    </ul>
                   
                </nav>
                <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper">
            <!-- ============================================================== -->
            <!-- Container fluid  -->
            <!-- ============================================================== -->
            <div class="container-fluid">
                <!-- ============================================================== -->
                <!-- Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <div class="card-block">
                    <h4 class="card-title" id="username22" style="font-weight: bold;color: blue;font-size: 30px; "></h4>
             <div class="table-responsive">
                 <img src="img/tx.jpeg" style="width: 150px;height: 150px; position: absolute; border: solid;" />
                 <label style="margin-left: 180px;" >账号：</label><input type="text" id="account1" readonly></input>
                  <label style="margin-left: 180px;">姓名：</label> <input type="text" id="username1" readonly></input><br />
                 <label style="margin-left: 180px;"> 密码：</label> <input type="password" id="password1"  readonly></input>
                 <label style="margin-left: 180px;">邮箱：</label>  <input type="text" id="email1" readonly></input><br />
                 <label style="margin-left: 180px;">电话：</label>  <input type="text" id="phone1" readonly></input><br />
                   
                   <button id="updata"style="margin-left: 180px;" >修改</button>
                   <button id="save" style="visibility: hidden;">保存</button>   
                   <hr />
                 <table class="table">
                     <thead>
                         <tr>
                            <!-- <th id="account">用户账号</th> -->
                             <th id="book_name">书号</th>
                             <th id="book_id">已借书籍</th>
                             <th id="date_borrow">借书日期</th>
                             <th id="date_return">到期日期</th>
                             <th >操作</th>
                         </tr>
                     </thead>
                     <tbody id="table1">
                         
                     </tbody>
                 </table>
             </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End Bread crumb and right sidebar toggle -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
               
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/plugins/bootstrap/js/tether.min.js"></script>
    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
    <script>
        
      function GetQueryString(account){
                      var reg = new RegExp("(^|&)"+ account +"=([^&]*)(&|$)");
                      var r = window.location.search.substr(1).match(reg);
                      if(r!=null)return  unescape(r[2]); return null;
      }
      var account= GetQueryString("account");
      
      var json = {"account":account};
        $.ajax({
            type:'post',
            url:"http://127.0.0.1:8080/updateUser",
            data: json,
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded", 
            success:function(data){
                // console.log(data.list)
                $('#account1').attr("value",data.username);
                $('#password1').attr("value",data.password);
                $('#email1').attr("value",data.email);
                $('#username1').attr("value",data.name);
                $('#phone1').attr("value",data.phone);       
                }  
        })
      function quit(){
          var r = confirm('确定注销?');
          if(r == true){
              window.location.href='http://127.0.0.1:8848/t/moban453/index.html';
          }
      }
      $('#updata').click(function(){
          document.getElementById("save").style.visibility="visible";
        
          // $('#password1').attr("readonly",false);
          $('#email1').attr("readonly",false);
          $('#username1').attr("readonly",false);
          $('#phone1').attr("readonly",false);
      })
      
      $('#updatePassword').click(function(){
         $('#password1').attr("readonly",false);
            var password = $('#password1').val();
      })
      $("#save").click(function(){
           var r = confirm("确定修改?");
           if(r==true){
               var account = $('#account1').val();
              
                var email = $('#email1').val();
               var username =  $('#username1').val();
                var phone = $('#phone1').val();
         var json = {"account":account,"email":email,"username":username,"phone":phone}
           
                $.ajax({
                    type:'post',
                    url:"http://127.0.0.1:8080/adminUpdateUser",
                    data: json,
                  
                    contentType: "application/x-www-form-urlencoded",  
                     success:function(){
                    
                            location.reload();
                         },
                         erroe: function(){
                             alert("保存失败！");
                         }
                })
                
           }
        
          
      })
      
      
      function back(book_id,id){
        
          var r = confirm("确定要归还此书籍吗？")
          if (r == true){
                var json = {"book_id":book_id,"id":id};
                $.ajax({
                    type:'post',
                    url:"http://127.0.0.1:8080/back",
                   contentType: "application/x-www-form-urlencoded", //传过去的数据类型，此为表单
                   data:json,
                   dataType:'json',
                    success:function(data){   
                       if(data.massage == 1){
                           alert("还书成功！");
                     location.reload();
                       }
                       else{
                           alert("系统故障，请稍后！");
                       }
                        }  
                }) 
              }
      }
      
      
    $("#a1").attr('href',"User_book.html?account="+account); 
    $("#a2").attr('href',"个人信息.html?account="+account);
        $.ajax({
            type:'post',
            url:"http://127.0.0.1:8080/selfInfo?account="+account,
            dataType:'json',
            success:function(data){ 
        console.log(data)
                $('#username22').text(data.username);
                
                for(var i=0;i<data.list.length;i++){
                    $("#table1").append("<tr><td hidden>"+data.list[i].id+"</td><td>"+data.list[i].book_id+"</td><td>"+data.list[i].book_name+"</td><td>"+data.list[i].date_borrow+"</td><td>"+data.list[i].date_return+"</td><td><a href=# onclick=back("+data.list[i].book_id+","+data.list[i].id+")>还书</a></td>");
                }
                },
                error:function(){
                    alert("错误");
                }
        })
    
    </script>
</body>

</html>
